#!/bin/bash
# -*- coding: utf-8 -*-
#Filename:   install.sh
#Author:     Yaoyi
#Email:      yaoyi@zzvcom.com
#Date:       2019-05-25 13:25:05
#Desc:       

#import need funciton and commond
source ../common/functions.sh
\cp -p proc/* /usr/bin

#set var
NAME=`basename $0`
dir=`pwd`
conf=$dir/DIRCONFIG.ini

function InstallDir() {
	for recode in `cat ${conf}|grep -v ^#`
	do
		if [[ X"${recode}" = X ]]
		then
			yaoecho hr "DIRCONFIG file have no content ! Please check it !"
			EchoErr ${LINENO}
			exit 1
		fi
		local whatfile=`echo ${recode}|awk -F "[=;]" '{print $1}'`
		local where=`echo ${recode}|awk -F "[=;]" '{print $2}'`
		if ([ X"${whatfile}" = X ] || [ X"${where}" = X ])
		then
			yaoecho hr "DIRCONFIG file format error, Please check it !"
			EchoErr ${LINENO}
			exit 1
		fi
		if [ ! -f ${dir}/../package/"${whatfile}".tgz ]
		then
			#
			yaoecho hr "${whatfile}.tgz : ${HOME_DIR}/source/package directory not exists this file"
			EchoErr ${LINENO}
			exit 1
		else
			if [ -d ${where} ]
			then
				mkdir -p ${where}
			fi
			cd ${dir}/../package/
			jdt "${whatfile}.tgz" "${where}"
		fi		
	done
}
 
InstallDir
